package com.springboot.activemq.topic;

import org.springframework.jms.JmsException;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.TextMessage;


/**
 * 主题消费者
 * @date 2020/10/8 15:46
 */
@Component
public class TopicConsumer {

    @JmsListener(destination = "${mytopic}")
    public void receive(TextMessage textMessage)throws JmsException{
        try {
            System.out.println("接收到消息-myTopic："+textMessage.getText());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

}
